package com.niit.service.impl;

import com.niit.dao.OrdersMapper;
import com.niit.pojo.Orders;
import com.niit.service.OrdersService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class OrdersServiceImpl implements OrdersService{
    private final OrdersMapper ordersMapper;

    public OrdersServiceImpl(OrdersMapper ordersMapper) {
        this.ordersMapper = ordersMapper;
    }

    @Override
    public boolean addOrder(Orders order) {
        return ordersMapper.insertOrder(order) > 0;
    }

    @Override
    public boolean deleteOrderById(int oid) {
        return ordersMapper.deleteOrderById(oid) > 0;
    }

    @Override
    public boolean updateOrder(Orders order) {
        return ordersMapper.updateOrder(order) > 0;
    }

    @Override
    public Orders getOrderById(int oid) {
        return ordersMapper.getOrderById(oid);
    }

    @Override
    public List<Orders> getAllOrders() {
        return ordersMapper.getAllOrders();
    }

    @Override
    public List<Orders> getOrdersByUserId(int uid) {
        return ordersMapper.getOrdersByUserId(uid);
    }
}
